package com.koron.housing.info.service;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.koron.bean.query.PageQuery;
import com.koron.housing.info.bean.dto.HousingInfoDTO;
import com.koron.housing.info.bean.dto.HousingInfoTree;
import com.koron.housing.info.bean.po.HousingInfo;
import com.koron.housing.info.bean.query.HousingInfoQuery;
import com.koron.housing.info.bean.vo.HousingInfoVO;
import org.koron.ebs.mybatis.SessionFactory;

import java.util.List;

/**
 * 房源台账(HousingInfo)表服务接口
 *
 * @author jzp
 * @since 2022-02-25 15:16:32
 */
public interface HousingInfoService {

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    HousingInfo getById(SessionFactory factory, String id);

    List<HousingInfo> list(SessionFactory factory, HousingInfoQuery query);

    /**
     * 查询所有数据
     *
     * @param query 查询条件对象
     * @return 列表结果集
     */
    List<HousingInfoDTO> listDto(SessionFactory factory, HousingInfoQuery query);

    List<HousingInfoVO> listVo(SessionFactory factory, HousingInfoQuery query);

    /**
     * 分页查询
     *
     * @param query 分页条件
     * @return 对象列表
     */
    default PageInfo<HousingInfoVO> page(SessionFactory factory, PageQuery pageQuery, HousingInfoQuery query) {
        PageHelper.startPage(pageQuery.getPage(), pageQuery.getPageSize(), pageQuery.getOrderBy());
        List<HousingInfoVO> housingInfoList = listVo(factory, query);
        return new PageInfo<>(housingInfoList);
    }

    List<HousingInfoTree> tree(SessionFactory factory);

    List<HousingInfo> address(SessionFactory factory, String propertySource);

    List<HousingInfo> village(SessionFactory factory, String propertySource);

    List<Boolean> hasExpiredHouse(SessionFactory factory);

    /**
     * 获取房源通知信息
     */
    String topic(SessionFactory factory);

    /**
     * 发送房源通知
     */
    void sendMessage(SessionFactory factory, String message);

    /**
     * 新增数据
     *
     * @param housingInfo 实例对象
     * @return 是否成功
     */
    boolean save(SessionFactory factory, HousingInfo housingInfo);

    boolean saveBatch(SessionFactory factory, List<HousingInfo> housingInfoList);

    /**
     * 修改数据
     *
     * @param housingInfo 实例对象
     * @return 是否成功
     */
    boolean update(SessionFactory factory, HousingInfo housingInfo);

    /**
     * 根据租赁信息自动更新房源状态
     */
    boolean autoStatus(SessionFactory factory, String id);

    boolean updateStatus(SessionFactory factory, String id, String status);

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    boolean deleteById(SessionFactory factory, String id);

    List<HousingInfo> listByContractId(SessionFactory factory, String contractId);
}
